package com.example.teaknow.Util.Weather;

import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.example.teaknow.MainActivity;
import com.google.gson.Gson;

/**
 * @Author: Stars
 */
public class GetWeather {

    private static String weather;
    public static void volleyGet() {
        StringBuffer Bufferurl=new StringBuffer();
        Bufferurl.append("http://apis.juhe.cn/simpleWeather/query?city=");
        Bufferurl.append("厦门");
        Bufferurl.append("&key=abe63651916c3be4a0cdf3c78329320f");
        String url=Bufferurl.toString();
        StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
              jsonStringParse(response);

            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                System.out.println(error);
                System.out.println("false");
            }
        });
        stringRequest.setTag("Get1");
        MyApplication.getHttpQueue().add(stringRequest);
    }

    private static void jsonStringParse(String response) {
        Gson gson=new Gson();
        Result result=gson.fromJson(response,Result.class);
        System.out.println(result.getResult().getFuture().get(0).getWid().getDay());
    }
}
